<script setup lang="ts">
import BtnGroup from "./BtnGroup.vue";
import IndexFooter from "./Common/IndexFooter.vue";
import FloatingBar from "./FloatingBar.vue";
import { onMounted, onUnmounted, ref } from "vue";
import "swiper/css";
import "swiper/css/navigation";
import { Swiper, SwiperSlide } from "swiper/vue";
import { Navigation } from "swiper/modules";
const modules = [Navigation];
declare var Wave: any;
let myWave: any = null;
const perView = ref(5);

const resizeEvent = () => {
  // change per view according to screen size
  perView.value =
    window.innerWidth < 950 ? Math.ceil(window.innerWidth / 285) : 5;
  // if (window.innerWidth < 950) {
  //   perView.value = 2;
  // } else {
  //   perView.value = 5;
  // }
};

onUnmounted(() => {
  myWave.destroy();
});

onMounted(() => {
  resizeEvent();
  window.addEventListener("resize", resizeEvent);
  setTimeout(() => {
    myWave = new Wave("#waves", {
      colors: [
        "rgba(255, 255, 255, 1)",
        "rgba(255, 255, 255, .6)",
        "rgba(255, 255, 255, .4)",
      ],
      smooth: 70,
      velocity: 0.6,
      position: "bottom",
      height: [70, 80, 90],
    });
    myWave.animate();
  }, 0);

  window.addEventListener("resize", () => {
    if (typeof myWave.init === 'function')
      myWave.init();
  });
});
// first swiper
const swipersData = ref([
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
  {
    img1: "./index/swiper1.png",
    img2: "./index/swiper1.png",
  },
]);
const swipersData2 = ref([
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
  {
    img1: "./index/swiper2.png",
    img2: "./index/swiper2.png",
  },
]);
</script>
<template>
  <div class="wave" id="waves"></div>
  <div class="wrap">
    <ul class="list">
      <li class="item">
        <span class="top">
          <img src="/index/stars.svg" alt="" />
        </span>
        <span class="bot">"操作很简单"</span>
      </li>
      <li class="item">
        <span class="top">
          <img src="/index/stars.svg" alt="" />
        </span>
        <span class="bot">"功能很强大"</span>
      </li>
      <li class="item">
        <span class="top">
          <img src="/index/stars.svg" alt="" />
        </span>
        <span class="bot">"真的很好用"</span>
      </li>
    </ul>
    <h1 class="title">
      安全高效的服务器运维面板
      <img src="/index/free.png" alt="" />
    </h1>
    <h3 class="instruction">
      <p>
        <span class="left">使用宝塔前：</span>
        <span class="right">
          手工输入命令安装各类软件，操作起来费时费力并且容易出错，而且需要记住很多Linux的命令，非常复杂。
        </span>
      </p>
      <p>
        <span class="left">使用宝塔后：</span>
        <span class="right">
          2分钟装好面板，一键管理服务器，鼠标点几下就能替代以前的复杂繁多命令，操作简单，看一眼就会使用。
        </span>
      </p>
    </h3>
    <BtnGroup />
    <h3 class="read">
      <span>7天内新增</span>
      <span class="num">41935</span>
      <span>台服务器安装使用宝塔，总装机量超过</span>
      <span class="num">1000万</span>
    </h3>
    <div class="visual">
      <img src="/index/mac.png" alt="" />
      <video src="/index/bt_video.mp4" autoplay muted loop></video>
      <img src="/index/shade.png" alt="" />
    </div>
    <h2 class="trust">受到1000+政企单位的信赖</h2>
    <div class="trustSwiper">
      <swiper :slides-per-view="perView" :space-between="perView === 2 ? 0 : 25" :modules="modules" :navigation="{
        nextEl: '.prevBtn',
        prevEl: '.nextBtn',
      }">
        <swiper-slide v-for="(item, index) in swipersData" :key="index">
          <div class="swiperBox">
            <img :src="item.img1" alt="swiper" />
          </div>
        </swiper-slide>
      </swiper>
      <div class="nextBtn">
        <i></i>
      </div>
      <div class="prevBtn">
        <i></i>
      </div>
    </div>
  </div>

  <div class="ocean">
    <div class="wave1"></div>
    <div class="wave2"></div>
  </div>

  <div class="example">
    <h3>人人都能上手的服务器运维管理工具</h3>
  </div>

  <div class="promoteBox">
    <ul class="promote">
      <li>
        <img src="/index/1.png" alt="" />
        <h3>简单聪明的可视化操作</h3>
        <p>简洁友好的交互体验，2分钟安装好面板</p>
        <p>一键安装LNMP/LAMP网站环境</p>
        <p>
          以网站管理为核心，提供资源监控、文件管理、软件安装等运维常用功能模块
        </p>
      </li>
      <li>
        <img src="/index/2.png" alt="" />
        <h3>简单聪明的可视化操作</h3>
        <p>简洁友好的交互体验，2分钟安装好面板</p>
        <p>一键安装LNMP/LAMP网站环境</p>
        <p>以网站管理为核心，提供资源监控、文件管</p>
        <p>理、软件安装等运维常用功能模块</p>
      </li>
      <li>
        <img src="/index/3.png" alt="" />
        <h3>简单聪明的可视化操作</h3>
        <p>简洁友好的交互体验，2分钟安装好面板</p>
        <p>一键安装LNMP/LAMP网站环境</p>
        <p>以网站管理为核心，提供资源监控、文件管</p>
        <p>理、软件安装等运维常用功能模块</p>
      </li>
    </ul>

    <div class="demo">
      <h3>安全高效的服务器运维面板</h3>
      <p>
        支持一键LAMP/LNMP/集群/监控/网站/FTP/数据库/JAVA等100多项服务器管理功能
      </p>

      <BtnGroup :gap="100" />
    </div>
  </div>

  <div class="billboard">
    <div class="inner">
      <div class="block">
        <div class="top">
          <h3>
            <i>1000</i>
            <span>万</span>
          </h3>
          <h4>安装</h4>
        </div>
        <div class="bot">海量用户选择 值得信赖</div>
      </div>

      <i class="line"></i>

      <div class="block">
        <div class="top">
          <h3>
            <i>1000</i>
            <span>+</span>
          </h3>
          <h4>安装</h4>
        </div>
        <div class="bot">海量用户选择 值得信赖</div>
      </div>

      <i class="line"></i>
      <div class="block">
        <div class="top">
          <h3>
            <i>1000</i>
            <span>+</span>
          </h3>
          <h4>安装</h4>
        </div>
        <div class="bot">海量用户选择 值得信赖</div>
      </div>

      <i class="line"></i>
      <div class="block">
        <div class="top">
          <h3>
            <i>1000</i>
            <span>+</span>
          </h3>
          <h4>安装</h4>
        </div>
        <div class="bot">海量用户选择 值得信赖</div>
      </div>
    </div>
  </div>

  <div class="companies">
    <h3>合作伙伴</h3>
    <p class="sub">申请IDC定制版合作</p>
  </div>

  <div class="companySwiper">
    <swiper :slides-per-view="perView" :space-between="perView === 2 ? 0 : 25" :modules="modules" :navigation="{
      nextEl: '.prevBtn2',
      prevEl: '.nextBtn2',
    }">
      <swiper-slide v-for="(item, index) in swipersData2" :key="index">
        <div class="swiperBox">
          <img :src="item.img1" alt="swiper" />
        </div>
      </swiper-slide>
    </swiper>
    <div class="nextBtn2">
      <i></i>
    </div>
    <div class="prevBtn2">
      <i></i>
    </div>
  </div>

  <IndexFooter />
  <FloatingBar />
</template>
<style lang="scss" scoped>
@import "../../utils/scss/global.scss";

#waves {
  position: absolute;
  // top: 130px;
  left: 0;
  width: 100%;
  height: 800px;
  background: linear-gradient(0deg, #d8efdb, #edf7ef);
  z-index: -1;
}

@include mobile {
  #app .wrap {
    width: 100%;
    padding: 0 15px;

    .list {
      display: none;
    }

    .title {
      width: 100%;
      font-size: 24px;

      img {
        width: 20px;
        height: 20px;
      }
    }

    .instruction {
      width: 100%;

      p {
        height: fit-content;
        font-size: 12px;
        text-align: center;

        span {
          font-size: 12px;
          line-height: 24px;
        }
      }
    }

    .read {
      flex-wrap: wrap;
    }

    .trust {
      font-size: 22px;
    }

    .trustSwiper {
      margin-top: 15px;

      .swiperBox {
        width: 165px;
      }
    }

    .visual {
      padding: 0;
    }
  }

  .ocean+.example {
    padding: 0 15px;

    h3 {
      font-size: 22px;
    }
  }

  .example+.promoteBox {
    .promote {
      width: 100%;
      flex-wrap: wrap;
      justify-content: center;

      li {
        width: 100%;
        padding: 18px 15px;

        img {
          width: 60px;
        }

        h3 {
          font-size: 16px;
          font-weight: bold;
        }

        p {
          width: 100%;
          text-align: center;
          font-size: 14px;
          line-height: 27px;
        }
      }
    }

    .demo {
      // text-align: center;
      // padding: 0 15px;
      margin-top: 45px;

      h3 {
        font-size: 22px;
        margin-top: 0px;
      }

      p {
        font-size: 14px;
        line-height: 27px;
        padding: 0 15px;
      }
    }
  }

  .promoteBox+.billboard {
    width: 100%;

    .inner {
      width: 100%;
      flex-direction: column;

      .line {
        width: 100%;
        height: 1px;
        margin: 15px 0;
      }
    }
  }

  .billboard+.companies {
    h3 {
      font-size: 22px;
    }
  }

  .companies+.companySwiper {
    width: 100%;

    .swiperBox {
      height: 80px;
    }
  }

  // .companySwiper + .footer {
  //   padding-top: 25px;
  //   .footerContent {
  //     width: 100%;
  //     padding: 0 15px;
  //     .top {
  //       flex-wrap: wrap;
  //       .imgBox {
  //         width: 100%;
  //         display: flex;
  //         justify-content: center;
  //         img {
  //           width: 100px;
  //         }
  //       }
  //       .qr {
  //         width: 100%;
  //         margin-top: 15px;
  //         p {
  //           font-size: 14px;
  //           line-height: 27px;
  //         }
  //       }
  //       .item {
  //         max-width: 33.33%;
  //         text-align: center;
  //         margin-top: 15px;
  //         h3 {
  //           font-weight: bold;
  //           font-size: 14px;
  //           line-height: 27px;
  //         }
  //         p {
  //           font-size: 12px;
  //           line-height: 22px;
  //           // margin-top: 5px;
  //           margin-bottom: 0;
  //           white-space: nowrap;
  //         }
  //       }
  //     }

  //     .bot {
  //       .group {
  //         p,
  //         a {
  //           font-size: 12px;
  //         }
  //       }
  //       .links {
  //         a {
  //           white-space: nowrap;
  //           font-size: 12px;
  //         }
  //       }
  //     }
  //   }
  // }
}

.wrap {
  width: $center;
  padding-top: 40px;
  margin: 0 auto;

  .trustSwiper {
    margin-top: 50px;
    position: relative;
    display: flex;
    align-items: center;

    @font-face {
      font-family: "FontAwesome";
      src: url("/index/fontawesome-webfont.eot?v=4.7.0");
      src: url("/index/fontawesome-webfont.eot?#iefix&v=4.7.0") format("embedded-opentype"),
        url("/index/fontawesome-webfont.woff2?v=4.7.0") format("woff2"),
        url("/index/fontawesome-webfont.woff?v=4.7.0") format("woff"),
        url("/index/fontawesome-webfont.ttf?v=4.7.0") format("truetype"),
        url("/index/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular") format("svg");
      font-weight: normal;
      font-style: normal;
    }

    .nextBtn {
      left: -50px;
    }

    .prevBtn {
      right: -50px;
      transform: rotateZ(180deg);
    }

    .prevBtn,
    .nextBtn {
      position: absolute;
      width: 42px;
      height: 42px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 42px;
      color: #999;

      &:hover {
        color: #20a53a;
      }

      i {
        display: inline-block;
        font: normal normal normal 14px / 1 FontAwesome;
        font-size: inherit;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        cursor: pointer;

        &::after {
          content: "\f104";
          font-family: "FontAwesome";
        }
      }
    }

    .swiper {
      --swiper-navigation-color: #20a53a;
      --swiper-navigation-size: 30px;
    }

    .swiperBox {
      width: 260px;
      height: 120px;
      border-radius: 8px;
      background: #f7f7f7;
      display: flex;
      align-items: center;
      justify-content: center;

      img {
        max-width: 90%;
        max-height: 70%;
      }
    }
  }

  .trust {
    font-size: 38px;
    text-align: center;
    margin-top: 50px;
    font-weight: bold;
  }

  .visual {
    width: 100%;
    margin-top: 50px;
    padding: 0 70px;

    img,
    video {
      width: 100%;
    }
  }

  .read {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-top: 20px;

    span {
      font-size: 20px;
      font-weight: normal;
      color: #333;
    }

    .num {
      font-size: 24px;
      color: #20a53a;
    }
  }

  .instruction {
    width: 994px;
    margin: 30px auto 0 auto;

    &>p {
      height: 32px;
      color: #424251;
    }

    &>p {
      span:nth-of-type(1) {
        font-size: 18px;
        line-height: 32px;
        font-weight: bold;
      }

      span:nth-of-type(2) {
        font-size: 18px;
        font-weight: normal;
      }
    }
  }

  h1 {
    font-weight: bold;
    font-size: 56px;
    color: #162016;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: normal;

    img {
      margin-left: 10px;
      width: 40px;
      height: 40px;
    }
  }

  .list {
    width: 100%;
    display: flex;
    justify-content: center;

    .item {
      width: 240px;
      height: 41.7px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;

      .bot {
        font-size: 16px;
        color: #909793;
      }

      .top {
        width: 85px;
        margin: 0 auto 2px;
      }
    }
  }

  //
}

.ocean {
  height: 200px;
  width: 100%;
  position: relative;
  bottom: -50px;
  z-index: 0;
  overflow: hidden;

  @keyframes waveAnimation {
    0% {
      margin-left: 0px;
    }

    100% {
      margin-left: -1600px;
    }
  }

  @keyframes swell {

    0%,
    100% {
      transform: translate3d(0, -25px, 0);
    }

    50% {
      transform: translate3d(0, 5px, 0);
    }
  }

  .wave1 {
    background: url(/index/wave.svg) repeat-x;
    position: absolute;
    top: 0px;
    width: 6400px;
    height: 198px;
    -webkit-animation: waveAnimation 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
    animation: waveAnimation 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
    transform: translate3d(0, 0, 0);
    opacity: 0.7;
  }

  .wave2 {
    background: url(/index/wave.svg) repeat-x;
    position: absolute;
    width: 6400px;
    height: 198px;
    transform: translate3d(0, 0, 0);
    top: 20px;
    -webkit-animation: waveAnimation 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) -0.125s infinite,
      swell 7s ease -1.25s infinite;
    animation: waveAnimation 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) -0.125s infinite,
      swell 7s ease -1.25s infinite;
    opacity: 0.7;
  }
}

.example {
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 1;
  background-color: #edf6ef;

  h3 {
    font-size: 38px;
    font-weight: bold;
    margin-bottom: 0;
  }
}

.promoteBox {
  width: 100%;
  background-color: #edf6ef;

  .promote {
    width: $center;
    padding-top: 50px;
    margin: -1px auto 0 auto;
    display: flex;
    justify-content: space-between;

    li {
      width: 23%;
      display: flex;
      flex-direction: column;
      align-items: center;

      img {
        width: 100px;
      }

      h3 {
        font-size: 24px;
        margin-top: 20px;
        color: #333;
      }

      p:nth-of-type(1) {
        margin-top: 15px;
      }

      p {
        text-align: center;
        font-size: 16px;
        line-height: 30px;
        color: #666;
      }
    }
  }

  .demo {
    h3 {
      width: 100%;
      text-align: center;
      font-size: 38px;
      font-weight: bold;
      margin-top: 80px;
    }

    h3+p {
      color: #20a53a;
      margin-top: 20px;
      text-align: center;
      font-size: 20px;
    }

    padding-bottom: 140px;
  }
}

.billboard {
  padding: 15px;
  background: #fff;
  color: #fff;
  position: relative;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.07);
  width: $center;
  margin: -90px auto 0;

  .inner {
    background: #20a53a;
    padding: 30px 5%;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .line {
      width: 1px;
      height: 55px;
      background: rgba(0, 0, 0, 0.3);
    }

    .block {
      display: flex;
      flex-direction: column;
      align-items: center;

      .bot {
        font-size: 18px;
        margin-top: 10px;
        line-height: 32px;
      }

      .top {
        display: flex;
        align-items: center;

        h3 {
          font-size: 60px;
          padding-right: 20px;
          margin-right: 15px;
          line-height: 60px;
          position: relative;

          i {
            $font: 60px;
            font-size: $font;
            line-height: $font;
            font-style: normal;
          }

          i+span {
            font-size: 16px;
            line-height: 30px;
            position: absolute;
            right: 0;
            top: 0;
          }
        }

        h3+h4 {
          font-size: 28px;
          font-weight: normal;
        }
      }
    }
  }
}

.companies {
  margin-top: 70px;

  h3 {
    font-size: 38px;
    font-weight: bold;
    text-align: center;
  }

  .sub {
    margin-top: 10px;
    font-size: 14px;
    color: #20a53a;
    text-align: center;
  }
}

.companySwiper {
  width: $center;
  margin: 30px auto 0;
  position: relative;
  display: flex;
  align-items: center;

  .nextBtn2 {
    left: -50px;
  }

  .prevBtn2 {
    right: -50px;
    transform: rotateZ(180deg);
  }

  .prevBtn2,
  .nextBtn2 {
    position: absolute;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    color: #999;

    &:hover {
      color: #20a53a;
    }

    i {
      display: inline-block;
      font: normal normal normal 14px / 1 FontAwesome;
      font-size: inherit;
      text-rendering: auto;
      -webkit-font-smoothing: antialiased;
      cursor: pointer;

      &::after {
        content: "\f104";
        font-family: "FontAwesome";
      }
    }
  }

  .swiperBox {
    height: 130px;
    margin: 10px;
    border-radius: 8px;
    /* filter: grayscale(100%); */
    filter: gray;
    display: flex;
    justify-content: center;
    align-items: center;

    img {
      max-width: 85%;
      max-height: 85%;
    }

    &:hover {
      background: #fff;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      filter: inherit;
    }
  }
}
</style>
